CMDS = [
	"Accessibility Options,access.cpl",
	"Add/Remove Programs,appwiz.cpl",
	"Add Hardware Wizard,hdwwiz.cpl",
	"Automatic Updates,wuaucpl.cpl",  
	"Bluetooth Properties,bthprops.cpl",  
	"Display Properties,desk.cpl",  
	"Firewall Properties,firewall.cpl",  
	"Game Controllers,joy.cpl",  
	"Internet Options,inetcpl.cpl",
	"iSCSI Initiator,iscsicpl.cpl",  
	"Java Control Panel,jpicpl32.cpl",   
	"Licensing Mode,liccpa.cpl",  
	"Mouse Properties,main.cpl",  
	"Network Connections,ncpa.cpl",
	"Network Setup Wizard,netsetup.cpl",  
	"ODBC Properties,odbccp32.cpl",  
	"Power Options,powercfg.cpl",  
	"Regional and Language Options,intl.cpl",  
	"Sound and Audio Devices,mmsys.cpl",
	"Stored Passwords,keymgr.cpl",
	"System Properties,sysdm.cpl",  
	"Telephone and Modem Properties,telephon.cpl",
	"Time and Date Settings,timedate.cpl",  
	"User Accounts,nusrmgr.cpl",
	"Windows Security Center,wscui.cpl",
	"Wireless Link,irprops.cpl",
	"Certificates,certmgr.msc",
	"Indexing Service,ciadv.msc",
	"Computer Management,compmgmt.msc",
	"Device Manager,devmgmt.msc",
	"Disk Defragmenter,dfrg.msc",
	"Disk Management,diskmgmt.msc",
	"Event Viewer,eventvwr.msc",
	"Shared Folders,fsmgmt.msc",
	"Group Policy,gpedit.msc",
	"Local Users and Groups,lusrmgr.msc",
	"Removable Storage,ntmsmgr.msc",
	"Removable Storage Operator Requests,ntmsoprq.msc",
	"Performance,perfmon.msc",
	"Resultant Set of Policy,rsop.msc",
	"Local Security Settings,secpol.msc",
	"Services,services.msc",
	"Windows Management Infrastructure (WMI),wmimgmt.msc",
	"Component Services,comexp.msc"
]



def show_cmds()
	puts "Commands in Control Panel:"
	puts "--------------------------------------------------------------------"

	$i = 0
	$j = 0
	while $i < (CMDS.size + 1) / 2 do
		item = CMDS[$i].split(',')
		print "#{$i.to_s.rjust(2)}: #{item[0]}".ljust(40)
		$j = $i + (CMDS.size + 1) / 2
		if $j < CMDS.size
			item = CMDS[$j].split(',')
			print "#{$j.to_s.rjust(2)}: #{item[0]}"
		end
		$i += 1
		puts ""
	end
end

def main()
	CMDS.sort! { |x,y| x.upcase <=> y.upcase }
	show_cmds()
	print "\nChoose a command to Run (0..#{CMDS.size-1}, 'q' to quit): "
	$choice = gets.strip
	
	if ($choice == "q") or !($choice =~ /^\d+$/)
		return
	end
	
	$choice = $choice.to_i

	if $choice.between?(0, CMDS.size - 1)
		item = CMDS[$choice].split(',')
		system("start #{item[1]}")
	elsif
		puts "Index of command is out of range."
	end
end

main()
